package com.crayfish.materiallearn;

import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.graphics.Palette;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 作者：crayfish(徐杰)
 * 描述：
 * Created by crayfish on 2017/5/3.
 */

public class UseImageActivity extends AppCompatActivity {

    private TextView txt_palette;
    private ImageView img_palette;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_useimage);
        initView();
        initEvent();
    }

    private void initView(){
        txt_palette = (TextView)super.findViewById(R.id.txt_palette);
        img_palette = (ImageView)super.findViewById(R.id.img_palette);
    }

    private void initEvent(){
        Palette palette = Palette.generate(BitmapFactory
                .decodeResource(getResources(),R.mipmap.ic_launcher));
        txt_palette.setBackgroundColor(palette.getLightVibrantSwatch().getRgb());
    }
}
